package com.ftd.exception;

import javax.servlet.http.HttpServletResponse;

/**
 * @author Peter on 2016-07-11.
 */
public class ApiException extends RuntimeException {

    private String message;

    private int httpStatus;

    public ApiException(int httpStatus, String message) {
        this.message = message;
        this.httpStatus = httpStatus;
    }


    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public int getHttpStatus() {
        return httpStatus;
    }

    public void setHttpStatus(int httpStatus) {
        this.httpStatus = httpStatus;
    }

    public static ApiException unauthorized(String message) {
        return new ApiException(HttpServletResponse.SC_UNAUTHORIZED, message);
    }
}
